Switch to libgsystem directory creation API
authorColin Walters <walters@verbum.org>
Thu, 29 Nov 2012 21:40:17 +0000 (16:40 -0500)
committerColin Walters <walters@verbum.org>
Thu, 29 Nov 2012 21:40:17 +0000 (16:40 -0500)
More code being dropped into a common place.

src/libgsystem
src/libostree/ostree-repo.c
src/libotutil/ot-gio-utils.c
src/libotutil/ot-gio-utils.h
src/ostree/ot-admin-builtin-deploy.c
src/ostree/ot-admin-builtin-update-kernel.c
src/ostree/ot-admin-functions.c

index 1332d9713365a53fae76570a3c484753f9bcbb30..ab2588da8442fc6135af13ee624dd91b73a7051c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1332d9713365a53fae76570a3c484753f9bcbb30
+Subproject commit ab2588da8442fc6135af13ee624dd91b73a7051c
index f3c2690746ecbd756dd9d37d80b2b6e1226099a8..d48ebd50e3d59da50a2b0eb19c09e622408ecee1 100644 (file)
@@ -477,7 +477,7 @@ write_checksum_file (GFile *parentdir,
     {
       child = g_file_get_child (parent, (char*)components->pdata[i]);
 
-      if (!ot_gfile_ensure_directory (child, FALSE, error))
+      if (!gs_file_ensure_directory (child, FALSE, NULL, error))
         goto out;
 
       g_clear_object (&parent);
@@ -622,7 +622,7 @@ ostree_repo_check (OstreeRepo *self, GError **error)
       goto out;
     }
 
-  if (!ot_gfile_ensure_directory (self->pending_dir, FALSE, error))
+  if (!gs_file_ensure_directory (self->pending_dir, FALSE, NULL, error))
     goto out;
   
   self->config = g_key_file_new ();
@@ -785,7 +785,7 @@ commit_loose_object_impl (OstreeRepo        *self,
   ot_lobj GFile *parent = NULL;
 
   parent = g_file_get_parent (dest);
-  if (!ot_gfile_ensure_directory (parent, FALSE, error))
+  if (!gs_file_ensure_directory (parent, FALSE, cancellable, error))
     goto out;
 
   if (is_regular)
@@ -1849,7 +1849,7 @@ ostree_repo_write_ref (OstreeRepo  *self,
     {
       dir = g_file_get_child (self->remote_heads_dir, remote);
 
-      if (!ot_gfile_ensure_directory (dir, FALSE, error))
+      if (!gs_file_ensure_directory (dir, FALSE, NULL, error))
         goto out;
     }
 
@@ -3400,7 +3400,7 @@ checkout_file_thread (GSimpleAsyncResult     *result,
         goto out;
 
       objdir = g_file_get_parent (loose_path);
-      if (!ot_gfile_ensure_directory (objdir, TRUE, error))
+      if (!gs_file_ensure_directory (objdir, TRUE, cancellable, error))
         {
           g_prefix_error (error, "Creating cache directory %s: ",
                           gs_file_get_path_cached (objdir));
index 14af2ce616b707541f9d552d2e48d9fb83e6b63e..1130225c5342a92d9c07204b82756464781bfeea 100644 (file)
@@ -49,45 +49,6 @@ ot_gfile_type_for_mode (guint32 mode)
     return G_FILE_TYPE_UNKNOWN;
 }
 
-gboolean
-ot_gfile_ensure_directory (GFile     *dir,
-                           gboolean   with_parents, 
-                           GError   **error)
-{
-  gboolean ret = FALSE;
-  GError *temp_error = NULL;
-
-  if (!g_file_make_directory (dir, NULL, &temp_error))
-    {
-      if (with_parents &&
-          g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
-        {
-          ot_lobj GFile *parent = NULL;
-
-          g_clear_error (&temp_error);
-
-          parent = g_file_get_parent (dir);
-          if (parent)
-            {
-              if (!ot_gfile_ensure_directory (parent, TRUE, error))
-                goto out;
-            }
-          if (!ot_gfile_ensure_directory (dir, FALSE, error))
-            goto out;
-        }
-      else if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
-        {
-          g_propagate_error (error, temp_error);
-          goto out;
-        }
-      else
-        g_clear_error (&temp_error);
-    }
-
-  ret = TRUE;
- out:
-  return ret;
-}
 
 GFile *
 ot_gfile_from_build_path (const char *first, ...)
@@ -220,7 +181,7 @@ cp_internal (GFile         *src,
   if (!enumerator)
     goto out;
 
-  if (!ot_gfile_ensure_directory (dest, FALSE, error))
+  if (!gs_file_ensure_directory (dest, FALSE, cancellable, error))
     goto out;
 
   while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, &temp_error)) != NULL)
@@ -231,7 +192,7 @@ cp_internal (GFile         *src,
 
       if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
         {
-          if (!ot_gfile_ensure_directory (dest_child, FALSE, error))
+          if (!gs_file_ensure_directory (dest_child, FALSE, cancellable, error))
             goto out;
 
           /* Can't do this even though we'd like to; it fails with an error about
index b96f1caa7f94a57063b4862da83028fdf2222d64..2481698480e636d2c27ee214458f2163e3686e17 100644 (file)
@@ -42,8 +42,6 @@ GFile *ot_gfile_get_child_strconcat (GFile *parent, const char *first, ...) G_GN
 
 GFile *ot_gfile_get_child_build_path (GFile *parent, const char *first, ...) G_GNUC_NULL_TERMINATED;
 
-gboolean ot_gfile_ensure_directory (GFile *dir, gboolean with_parents, GError **error);
-
 gboolean ot_gfile_load_contents_utf8 (GFile         *file,
                                       char         **contents_out,
                                       char         **etag_out,
index 27b7ce75e6d9d3f447e4d9adcdd6b7b636dc81e1..e7681b93a0b81fe0453483fc8cd10f6fa5747ce1 100644 (file)
@@ -229,7 +229,7 @@ copy_one_config_file (OtAdminDeploy      *self,
   parent = g_file_get_parent (dest);
 
   /* FIXME actually we need to copy permissions and xattrs */
-  if (!ot_gfile_ensure_directory (parent, TRUE, error))
+  if (!gs_file_ensure_directory (parent, TRUE, cancellable, error))
     goto out;
 
   if (!g_file_copy (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA,
@@ -392,7 +392,7 @@ deploy_tree (OtAdminDeploy     *self,
   deploy_target_path_tmp = g_file_resolve_relative_path (deploy_dir, deploy_target_fullname_tmp);
 
   deploy_parent = g_file_get_parent (deploy_target_path);
-  if (!ot_gfile_ensure_directory (deploy_parent, TRUE, error))
+  if (!gs_file_ensure_directory (deploy_parent, TRUE, cancellable, error))
     goto out;
 
   deploy_target_etc_name = g_strconcat (deploy_target, "-", resolved_commit, "-etc", NULL);
index 0629bfeb2d3660ace8c5234073a3db4ee4f27bbb..b944d0e51f2ebfab1cd6b7bc94a8f2bce3e59759 100644 (file)
@@ -53,7 +53,7 @@ copy_modules (OtAdminUpdateKernel *self,
   src_modules_file = ot_gfile_from_build_path ("/lib/modules", release, NULL);
   dest_modules_file = ot_gfile_get_child_build_path (self->ostree_dir, "modules", release, NULL);
   dest_modules_parent = g_file_get_parent (dest_modules_file);
-  if (!ot_gfile_ensure_directory (dest_modules_parent, FALSE, error))
+  if (!gs_file_ensure_directory (dest_modules_parent, FALSE, cancellable, error))
     goto out;
 
   if (!g_file_query_exists (dest_modules_file, cancellable))
index 6ddb76816b07beb4c9cc5873a80977a2e5d0ce11..c291e9e099f4d2a19fe61b651ac5bb2c513804a7 100644 (file)
@@ -36,17 +36,17 @@ ot_admin_ensure_initialized (GFile         *ostree_dir,
 
   g_clear_object (&dir);
   dir = g_file_get_child (ostree_dir, "repo");
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
 
   g_clear_object (&dir);
   dir = g_file_get_child (ostree_dir, "deploy");
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
 
   g_clear_object (&dir);
   dir = g_file_get_child (ostree_dir, "modules");
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
 
   g_clear_object (&dir);
@@ -70,12 +70,12 @@ ot_admin_ensure_initialized (GFile         *ostree_dir,
    */
   g_clear_object (&dir);
   dir = ot_gfile_get_child_build_path (ostree_dir, "var", "log", NULL);
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
 
   g_clear_object (&dir);
   dir = ot_gfile_get_child_build_path (ostree_dir, "var", "tmp", NULL);
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
   if (chmod (gs_file_get_path_cached (dir), 01777) < 0)
     {
@@ -85,7 +85,7 @@ ot_admin_ensure_initialized (GFile         *ostree_dir,
 
   g_clear_object (&dir);
   dir = ot_gfile_get_child_build_path (ostree_dir, "var", "lib", NULL);
-  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+  if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
     goto out;
 
   g_clear_object (&dir);